package crazy.serializable;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;


public class TransientTest
{
	public static void main(String[] args)
	{
		ObjectInputStream ois = null;
		ObjectOutputStream oos = null;
		try
		{
			oos = new ObjectOutputStream(new FileOutputStream("transient.txt"));
			Person per = new Person("sun wukong", 500);
			oos.writeObject(per);
			
			ois = new ObjectInputStream(new FileInputStream("transient.txt"));
			Person p = (Person) ois.readObject();
			System.out.println(p.getAge());
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			try
			{
				if (ois !=null)
				{
					ois.close();
				}
			}
			catch (Exception e2)
			{
				e2.printStackTrace();
			}
			
			try
			{
				if (oos != null)
				{
					oos.close();
				}
			}
			catch (Exception e2)
			{
				e2.printStackTrace();
			}
		}
	}
}
